<?
class Typeunit {
    /**
     *  读出所有分类,在类目管理页(list_type)中使用
     *
     * @access    public
     * @param     int   $table  表名
     * @param     int   $topid  当前操作ID
     * @return    string
     */
     public function ListType($table='keshi',$topid=0){
        $Form = M($table);
		$map['topid'] = $topid;
		$map['yiyuanid'] = htmlspecialchars($_GET['yiyuanid']);
		$map['status'] = 1;
        $list = $Form->field('keshi.*,yiyuan.name as yiyuan')->where($map)->join('yiyuan on yiyuan.id=keshi.yiyuanid')->order("sort desc,keshi.id asc")->select();
        foreach ($list as $k => $v) {
             echo '<tr align="center"  bgcolor="#FBFCE2" height="22" class="fid"><td width="7%"><span class="jia"></span>'.$v['id'].'</td><td width="14%">'.$v['yiyuan'].'</td><td width="14%">'.$v['name'].'</td><td><span class="coolbg" onClick="winopen(\'__URL__/keshi_edit/yiyuanid/'.$v['yiyuanid'].'/id/'.$v['id'].'\',\'id'.$v['id'].'\',1000,650)">科室编辑</span>&nbsp;&nbsp;<span alt="'.$v['id'].'" title="'.$v['name'].'" class="ksjb">科室疾病</span>&nbsp;&nbsp;<a href="__GROUP__/Yisheng/index/yiyuanid/'.$v['yiyuanid'].'/keshiid/'.$v['id'].'" class="coolbg">医生管理</a>&nbsp;&nbsp;<a href="__URL__/keshi_del/yiyuanid/'.$v['yiyuanid'].'/id/'.$v['id'].'" class="coolbg">科室删除</a></td></tr>';
			 $this->ListTypeSeed($table,$v['id']);
         } 
    }
	
    /**
     *  读出子分类
     *
     * @access    public
     * @param     int   $table  表名
     * @param     int   $topid  当前操作ID
     * @return    string
     */
	private function ListTypeSeed($table,$topid){
        $Form = M($table);
        $map['topid'] = $topid;
		$map['yiyuanid'] = htmlspecialchars($_GET['yiyuanid']);
		$map['status'] = 1;
        $list = $Form->field('keshi.*,yiyuan.name as yiyuan')->where($map)->join('yiyuan on yiyuan.id=keshi.yiyuanid')->order("sort desc,keshi.id asc")->select();
		if($list){
			echo '<tr align="center"  bgcolor="#FFFFFF" height="22" class="seed"><td colspan="4"><table width="98%">';
			foreach ($list as $k => $v) {
				 echo '<tr align="center" bgcolor="#FAFAF1" height="22" class="fid"><td width="7%"><span class="jia"></span>'.$v['id'].'</td><td width="14%">'.$v['yiyuan'].'</td><td width="14%">'.$v['name'].'</td><td><span class="coolbg" onClick="winopen(\'__URL__/keshi_edit/yiyuanid/'.$v['yiyuanid'].'/id/'.$v['id'].'\',\'id'.$v['id'].'\',1000,650)">科室编辑</span>&nbsp;&nbsp;<span alt="'.$v['id'].'" title="'.$v['name'].'" class="ksjb">科室疾病</span>&nbsp;&nbsp;<a href="__GROUP__/Yisheng/index/yiyuanid/'.$v['yiyuanid'].'/keshiid/'.$v['id'].'" class="coolbg">医生管理</a>&nbsp;&nbsp;<a href="__URL__/keshi_del/yiyuanid/'.$v['yiyuanid'].'/id/'.$v['id'].'" class="coolbg">科室删除</a></td></tr>';
				 $this->ListTypeSeed("keshi",$v['id']);
			 }
			echo '</table></td></tr>';
		}
	}
}
?>